Shader program helping sources for general geometry concepts. More...
Static Public Member Functions | |
| static nkMemory::StringView | nkGetSphereIntersection () |
| static nkMemory::StringView | nkSphericalToDirection () |
| static nkMemory::StringView | nkDirectionToUv () |
| static nkMemory::StringView | nkUvToDirection () |
Shader program helping sources for general geometry concepts.
|
static |
Provides with a sphere ray intersection algorithm.
| Parameter | Description |
|---|---|
| o | The ray's origin position, relative to the sphere's center. |
| d | The normalized ray's direction. |
| radius | The sphere radius. |
| Returns | |
| The distance at which the intersection happens, positive if forward, negative if behind. If no intersection is found, then -1. | |
The returned distance r allows to reconstruct the intersection position as such : p = r * d + o.
|
static |
Converts spherical coordinates into a cartesian 3D direction.
| Parameter | Description |
|---|---|
| theta | The theta angle of the input coordinates. |
| phi | The phi angle of the input coordinates. |
| Returns | |
| The corresponding 3D direction. | |
|
static |
Converts a world direction into a texture UV, by mapping it like a sphere.
| Parameter | Description |
|---|---|
| direction | The direction to convert. |
| Returns | |
| The corresponding texture UV, in [0, 1]. | |
|
static |
Converts a texture UV within [0, 1] to a world direction, by mapping it to a sphere.
| Parameter | Description |
|---|---|
| uv | The UV to convert. |
| Returns | |
| The corresponding normalized direction. | |